home *** CD-ROM | disk | FTP | other *** search
Wrap
// ToolList.cpp : implementation file // #include "stdafx.h" #include "InsTool.h" #include "ToolList.h" #include "TDialog.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // ToolList CToolList::CToolList() { // EnableAutomation(); } CToolList::~CToolList() { } void CToolList::OnFinalRelease() { // When the last reference for an automation object is released // OnFinalRelease is called. The base class will automatically // deletes the object. Add additional cleanup required for your // object before calling the base class. CListBox::OnFinalRelease(); } BEGIN_MESSAGE_MAP(CToolList, CListBox) //{{AFX_MSG_MAP(CToolList) ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_WM_MOUSEMOVE() ON_CONTROL_REFLECT(LBN_SELCHANGE, OnSelchange) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // ToolList message handlers void CToolList::RefreshFileList(CString path) { struct _finddata_t c_file; long hFile; hFile = 0; // int i = _chdir("c:\\SYMBOLS"); // the directory that contains symbols. int i = _chdir(path); // the directory that contains symbols. ResetContent(); m_cstrCurSelected = ""; /* Find first .c file in current directory */ if (i == 0) { if( (hFile = _findfirst( "*.tcw", &c_file )) != -1L )//# Non-localizable string# { /* Find the rest of the .c files */ AddString(c_file.name); //add first file to the list while( _findnext( hFile, &c_file ) == 0 ) { AddString(c_file.name); } _findclose( hFile ); } // else // MessageBox("Selected directory doesn't contain *.tcw files", "Warning", MB_OK); } } void CToolList::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CListBox::OnLButtonDown(nFlags, point); BOOL ret; m_LB_DOWNpoint.x = point.x; m_LB_DOWNpoint.y = point.y; CString cstrSelected = ""; CListBox *pList = (CListBox *) (GetParent()->GetDlgItem(IDC_LIST1)); UINT index = ItemFromPoint(point, ret); if (ret == FALSE) { m_drag = TRUE; GetText(index, cstrSelected); } if (m_cstrCurSelected != cstrSelected && cstrSelected != "") // check if the current selection is changed { BeginWaitCursor(); CViewWnd *pView = (CViewWnd *) (((CTDialog*)GetParent())->GetDlgItem(IDC_PREVIEW)); pView->ClearAll(); int index = pList->GetCurSel(); BOOL a = FALSE; a = pView->CreatePreview(); if(a == FALSE) return; a = FALSE; a = pView->DoPreview(); if (a = FALSE) { CString szMess; CString szCap; szMess.LoadString(IDS_STRING105); szCap.LoadString(IDS_STRING106); //MessageBox("The drawing have Brush styles or Line styles different from default. This sample can't work with such files", "ERROR!", MB_OK);//# Localizable string# MessageBox(LPCTSTR(szMess),LPCTSTR(szCap), MB_OK); pList->DeleteString(index); } m_cstrCurSelected = cstrSelected; pView->Invalidate(); EndWaitCursor(); } } void CToolList::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CListBox::OnLButtonUp(nFlags, point); m_drag = FALSE; CPoint Pt = point; ClientToScreen(&Pt); CWnd *pClickWNd = WindowFromPoint(Pt); if(pClickWNd && pClickWNd != this) { pClickWNd->ScreenToClient(&Pt); pClickWNd->PostMessage(WM_LBUTTONUP, nFlags, MAKELONG(Pt.x, Pt.y)); SetCursor(m_OldCursor); ShowCursor(TRUE); return; } else { SetCursor(m_OldCursor); ShowCursor(TRUE); // ((CTDialog*)GetParent())->DisconectEvents(); } } void CToolList::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if(nFlags & MK_LBUTTON) { int dx = m_LB_DOWNpoint.x - point.x; int dy = m_LB_DOWNpoint.y - point.y; CPoint Pt = point; if((abs(dx) > 1 || abs(dy) > 1) && m_drag) { // if dragging if (((CTDialog*)GetParent())->m_dwEventConnection == 0) { ((CTDialog*)GetParent())->ConnectEvents(); } m_OldCursor = GetCursor(); m_NewCursor = LoadCursor(AfxGetInstanceHandle( ), MAKEINTRESOURCE(IDC_CURSOR1)); SetCursor(m_NewCursor); ShowCursor(TRUE); m_drag = FALSE; m_LB_DOWNpoint.x = -1; m_LB_DOWNpoint.y = -1; ((CTDialog*)GetParent())->m_FirstClick = TRUE; return; } ClientToScreen(&Pt); CWnd *pClickWNd = WindowFromPoint(Pt); if(pClickWNd && pClickWNd != this) { pClickWNd->ScreenToClient(&Pt); pClickWNd->PostMessage(WM_MOUSEMOVE, nFlags, MAKELONG(Pt.x, Pt.y)); } } } void CToolList::OnSelchange() { // TODO: Add your control notification handler code here CListBox *pList = (CListBox *) (GetParent()->GetDlgItem(IDC_LIST1)); int index = pList->GetCurSel(); CString cstrSelected; HCURSOR hOC = ::SetCursor(::LoadCursor(NULL,IDC_WAIT)); pList->GetText(index, cstrSelected); if (m_cstrCurSelected != cstrSelected && cstrSelected != "") { CViewWnd *pView = (CViewWnd *) (((CTDialog*)GetParent())->GetDlgItem(IDC_PREVIEW)); pView->ClearAll(); BOOL a = FALSE; a = pView->CreatePreview(); if(a == FALSE) return; a = FALSE; a = pView->DoPreview(); if (a = FALSE) { CString szMess; CString szCap; szMess.LoadString(IDS_STRING105); szCap.LoadString(IDS_STRING106); //MessageBox("The drawing have Brush styles or Line styles different from default. This sample can't work with such files", "ERROR!", MB_OK);//# Localizable string# MessageBox(LPCTSTR(szMess),LPCTSTR(szCap), MB_OK); pList->DeleteString(index); } m_cstrCurSelected = cstrSelected; } ::SetCursor(hOC); }